// Copyright 2020 Apple Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-unwrapdatetimeformat
description: >
    Tests that [[FallbackSymbol]]'s [[Description]] is "IntlLegacyConstructedSymbol" if normative optional is implemented.
author: Yusuke Suzuki
features: [intl-normative-optional]
---*/

function Test() {
    let object = new Intl.DateTimeFormat();
    let newObject = Intl.DateTimeFormat.call(object);
    let symbol = null;
    let error = null;
    try {
        let proxy = new Proxy(newObject, {
            get(target, property) {
                symbol = property;
                return target[property];
            }
        });
        Intl.DateTimeFormat.prototype.resolvedOptions.call(proxy);
    } catch (e) {
        // If normative optional is not implemented, an error will be thrown.
        error = e;
        assert(error instanceof TypeError);
    }
    if (error === null) {
          assert.sameValue(typeof symbol, "symbol");
          assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol");
    }
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
